﻿<phone:PhoneApplicationPage 
    x:Class="SSTU.View.GroupTimeTablePage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
	xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
	xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
		xmlns:interactivity="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
	xmlns:interaction="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="728"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
	DataContext="{Binding Path=GroupTimeTableViewModel, Source={StaticResource ViewModelLocator}}">

	<phone:PhoneApplicationPage.Resources>
		<DataTemplate x:Key="GroupLessonItemDataTemplate">
			<StackPanel Margin="0,0,0,12">
				<TextBlock>
					<Run Text="{Binding Path=StartString, Mode=OneTime}" />
					<Run Text="-" />
					<Run Text="{Binding Path=EndString, Mode=OneTime}" />
					<Run Text="," />
					<Run Text="{Binding Path=FullRoomId, Mode=OneTime}" />
				</TextBlock>
				<TextBlock Text="{Binding Path=Theme, Mode=OneTime}" />
				<TextBlock Text="{Binding Path=Lecturer.FullName, Mode=OneTime}" />
			</StackPanel>
		</DataTemplate>
		<DataTemplate x:Key="DayItemDataTemplate">
			<StackPanel Margin="0,0,0,24">
				<TextBlock Text="{Binding Path=DayString}" Foreground="{StaticResource PhoneAccentBrush}" />
				<ItemsControl ItemsSource="{Binding Path=Classes}" ItemTemplate="{StaticResource GroupLessonItemDataTemplate}" />
			</StackPanel>
		</DataTemplate>
	</phone:PhoneApplicationPage.Resources>

	<Grid x:Name="LayoutRoot" Background="Transparent">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>
		<toolkit:PerformanceProgressBar IsIndeterminate="{Binding Path=IsBusy}" />
		<TextBlock Margin="24,24,24,0" Grid.Row="1">
			<Run Text="{Binding Path=Group.ShortName, Mode=OneWay}" FontSize="{StaticResource PhoneFontSizeLarge}"/>
			<LineBreak />
			<Run Text="{Binding Path=WeekTypeString, Mode=TwoWay}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneAccentBrush}" />
			<Run Text="неделя" FontSize="{StaticResource PhoneFontSizeNormal}" />
		</TextBlock>
		<controls:Pivot Grid.Row="2">
			<controls:PivotItem Header="нечетная">
				<ScrollViewer Margin="12,0,-12,0">
					<Grid>
						<TextBlock Text="&lt;пусто&gt;" Margin="0" Style="{StaticResource PhoneTextSubtleStyle}" DataContext="{Binding}">
							<interaction:Interaction.Triggers>
								<interactivity:DataTrigger Binding="{Binding Path=OddWeek.Days.Count}" Value="0" Comparison="Equal">
									<interactivity:ChangePropertyAction PropertyName="Visibility">
										<interactivity:ChangePropertyAction.Value>
											<Visibility>Visible</Visibility>
										</interactivity:ChangePropertyAction.Value>
									</interactivity:ChangePropertyAction>
								</interactivity:DataTrigger>
								<interactivity:DataTrigger Binding="{Binding Path=OddWeek.Days.Count}" Value="0" Comparison="NotEqual">
									<interactivity:ChangePropertyAction PropertyName="Visibility">
										<interactivity:ChangePropertyAction.Value>
											<Visibility>Collapsed</Visibility>
										</interactivity:ChangePropertyAction.Value>
									</interactivity:ChangePropertyAction>
								</interactivity:DataTrigger>
							</interaction:Interaction.Triggers>
						</TextBlock>
						<ItemsControl ItemsSource="{Binding Path=OddWeek.Days}" Margin="0,0,24,0" ItemTemplate="{StaticResource DayItemDataTemplate}" />
					</Grid>
				</ScrollViewer>
			</controls:PivotItem>
			<controls:PivotItem Header="четная">
				<ScrollViewer Margin="12,0,-12,0">
					<Grid>
						<TextBlock Text="&lt;пусто&gt;" Margin="0" Style="{StaticResource PhoneTextSubtleStyle}">
							<interaction:Interaction.Triggers>
								<interactivity:DataTrigger Binding="{Binding Path=EvenWeek.Days.Count}" Value="0" Comparison="Equal">
									<interactivity:ChangePropertyAction PropertyName="Visibility">
										<interactivity:ChangePropertyAction.Value>
											<Visibility>Visible</Visibility>
										</interactivity:ChangePropertyAction.Value>
									</interactivity:ChangePropertyAction>
								</interactivity:DataTrigger>
								<interactivity:DataTrigger Binding="{Binding Path=EvenWeek.Days.Count}" Value="0" Comparison="NotEqual">
									<interactivity:ChangePropertyAction PropertyName="Visibility">
										<interactivity:ChangePropertyAction.Value>
											<Visibility>Collapsed</Visibility>
										</interactivity:ChangePropertyAction.Value>
									</interactivity:ChangePropertyAction>
								</interactivity:DataTrigger>
							</interaction:Interaction.Triggers>
						</TextBlock>
						<ItemsControl ItemsSource="{Binding Path=EvenWeek.Days}" Margin="0,0,24,0" ItemTemplate="{StaticResource DayItemDataTemplate}" />
					</Grid>
				</ScrollViewer>
			</controls:PivotItem>
		</controls:Pivot>
	</Grid>
	
	<phone:PhoneApplicationPage.ApplicationBar>
		<shell:ApplicationBar Mode="Default">
			<shell:ApplicationBar.MenuItems>
				<shell:ApplicationBarMenuItem Click="OnFavoriteMenuItemClick" Text="статус не определен" />
			</shell:ApplicationBar.MenuItems>
		</shell:ApplicationBar>
	</phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>
